import java.util.LinkedList;


public class Stack {
	
	LinkedList<StackEntry> stack = null;
	
	public Stack() {
		super();
	}
	
	public void pushEntry(SymbolTable tablePointer) {
		pushEntry(new StackEntry(tablePointer));
	}
	
	public void pushEntry(StackEntry entry) {
		if(entry != null) {
			if(this.stack == null)
				this.stack = new LinkedList<StackEntry>();
			this.stack.push(entry);
		}
	}
	
	public void popEntry() {
		if(this.stack != null && this.stack.size() > 0)
			this.stack.pop();
	}
	
	public void incrementTopEntryByValue(int value) {
		if(this.stack != null && this.stack.size() > 0)
			this.stack.getFirst().incrementOffsetByValue(value);
	}
	
	public SymbolTable getTopTablePointer() {
		if(this.stack != null && this.stack.size() > 0)
			return this.stack.getFirst().getTablePointer();
		else
			return null;
	}
	
	public StackEntry getTopEntry() {
		if(this.stack != null && this.stack.size() > 0)
			return this.stack.getFirst();
		else
			return null;
	}
}
